import {Constant} from '../Constant.js';
import {RecordValueDataFormat} from './RecordValueDataFormat.js';
import {DataSource} from './DataSource.js';
import {TableAttribute} from './TableAttribute.js';
class TableElement {
  constructor(isNeedBindPoint = Constant.NEED_TO_BIND_POINT, tableAttribute = new TableAttribute(), elementDataList = [],
    elementView = {}, dataFormat = new RecordValueDataFormat(), dataSource = new DataSource()) {
    this.tableAttribute = tableAttribute;
    this.elementDataList = elementDataList;
    this.elementView = elementView;
    this.isNeedBindPoint = isNeedBindPoint;
    this.dataFormat = dataFormat;
    this.dataSource = dataSource;
    this.isCustomElement = false;
    this.originLabelName = tableAttribute.labelName;
  }
  putDataIntoDataList(dataValue) {
    let value = dataValue;
    if (this.dataFormat) {
      value = this.dataFormat.formatData(value);
    }
    this.elementDataList.push(value);
  }
  putDatasIntoDataList(datas) {
    this.elementDataList = [...this.elementDataList, ...datas];
  }
  resetDataList(num, value) {
    if ((this.elementDataList).length > 0 && this.elementDataList[0] === value) {
      return;
    }
    this.elementDataList.splice(0, this.elementDataList.length);
    for (let i = 0; i < num; i++) {
      this.elementDataList.push(value);
    }
  }
}
export {
  TableElement
};